package com.nbsaas.sample.user.rest.resource;

import com.nbsaas.sample.user.api.apis.UserAddressApi;
import com.nbsaas.sample.entity.user.UserAddress;
import com.nbsaas.sample.user.api.domain.request.UserAddressDataRequest;
import com.nbsaas.sample.user.api.domain.response.UserAddressResponse;
import com.nbsaas.sample.user.api.domain.simple.UserAddressSimple;
import com.nbsaas.sample.user.rest.convert.UserAddressSimpleConvert;
import com.nbsaas.sample.user.rest.convert.UserAddressEntityConvert;
import com.nbsaas.sample.user.rest.convert.UserAddressResponseConvert;
import com.nbsaas.sample.user.data.repository.UserAddressRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;

/**
*   业务接口实现
*/
@Transactional
@Service
public class UserAddressResource extends BaseResource<UserAddress,UserAddressResponse, UserAddressSimple, UserAddressDataRequest>  implements UserAddressApi {

    @Resource
    private UserAddressRepository userAddressRepository;

    @Override
    public JpaRepositoryImplementation<UserAddress, Serializable> getJpaRepository() {
        return userAddressRepository;
    }

    @Override
    public Function<UserAddress, UserAddressSimple> getConvertSimple() {
        return new UserAddressSimpleConvert();
    }

    @Override
    public Function<UserAddressDataRequest, UserAddress> getConvertForm() {
        return new UserAddressEntityConvert();
    }

    @Override
    public Function<UserAddress, UserAddressResponse> getConvertResponse() {
        return new UserAddressResponseConvert();
    }

}


